package com.cloud.wms.ui.in.inventory;

import android.content.Context;
import android.content.Intent;
import android.os.Message;
import android.view.View;
import android.widget.TextView;

import com.cloud.wms.R;
import com.cloud.wms.base.BaseBarActivity;
import com.cloud.wms.config.IntentKey;
import com.cloud.wms.ui.in.contract.InInventoryContract;
import com.cloud.wms.ui.in.entity.InOrderEntity;
import com.cloud.wms.ui.in.presnter.InInventoryPresenter;
import com.cloud.wms.ui.main.entity.TaskEntity;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * @Author:Chen
 * @Date: 2021-01-22 17:50
 * @Description:
 */
public class InTypeActivity extends BaseBarActivity<InInventoryPresenter> implements InInventoryContract.View {
    @BindView(R.id.tv_title)
    TextView tvTitle;
    @BindView(R.id.tv_in_mark)
    TextView tvInMark;
    @BindView(R.id.tv_in_batch)
    TextView tvInBatch;
    @BindView(R.id.tv_in_single)
    TextView tvInSingle;
    private InOrderEntity orderEntity;
    private TaskEntity taskEntity;

    @Override
    protected String barTitle() {
        return "清点方式";
    }

    @Override
    protected int getResId() {
        return R.layout.activity_in_type;
    }

    @Override
    protected void setupComponent() {
        getActivityComponent().inject(this);
    }

    @Override
    protected void initEvent() {
        tvTitle.setText(barTitle());
        tvInMark.setText("箱唛清点");
        tvInBatch.setText("批量清点");
        tvInSingle.setText("逐件清点");
        orderEntity = getIntent().getParcelableExtra(IntentKey.OBJECT_KEY);
        taskEntity = getIntent().getParcelableExtra(IntentKey.TASK_KEY);
    }

    @Override
    public void onSuccess(Message message) {

    }

    @OnClick({R.id.tv_in_mark, R.id.tv_in_batch, R.id.tv_in_single})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_in_mark:
                if (orderEntity == null && taskEntity == null) {
                    NoMarkActivity.start(this);
                } else {
                    HaveMarkActivity.start(this, taskEntity, orderEntity);
                }
                this.finish();
                break;
            case R.id.tv_in_batch:
                if (orderEntity == null && taskEntity == null) {
                    NoBatchActivity.start(this);
                } else {
                    HaveBatchActivity.start(this, taskEntity, orderEntity);
                }
                this.finish();
                break;
            case R.id.tv_in_single:
                if (orderEntity == null && taskEntity == null) {
                    NoSingleActivity.start(this);
                } else {
                    HaveSingleActivity.start(this, taskEntity, orderEntity);
                }
                this.finish();
                break;
        }
    }

    public static void start(Context context, InOrderEntity orderEntity) {
        Intent intent = new Intent(context, InTypeActivity.class);
        intent.putExtra(IntentKey.OBJECT_KEY, orderEntity);
        context.startActivity(intent);
    }

    public static void start(Context context, TaskEntity taskEntity, InOrderEntity inOrderEntity) {
        Intent intent = new Intent(context, InTypeActivity.class);
        intent.putExtra(IntentKey.OBJECT_KEY, inOrderEntity);
        intent.putExtra(IntentKey.TASK_KEY, taskEntity);
        context.startActivity(intent);
    }
}
